<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->

	<link href="/public/simpleboot/themes/<?php echo C('SP_ADMIN_STYLE');?>/theme.min.css" rel="stylesheet">
    <link href="/public/simpleboot/css/simplebootadmin.css" rel="stylesheet">
    <link href="/public/js/artDialog/skins/default.css" rel="stylesheet" />
    <link href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome.min.css"  rel="stylesheet" type="text/css">
    <style>
		.length_3{width: 180px;}
		form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
		.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;}
		.table-list{margin-bottom: 0px;}
	</style>
	<!--[if IE 7]>
	<link rel="stylesheet" href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome-ie7.min.css">
	<![endif]-->
<script type="text/javascript">
//全局变量
var GV = {
    DIMAUB: "/",
    JS_ROOT: "public/js/",
    TOKEN: ""
};
document.domain = "xinhuiwen.com";
</script>
<!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/public/js/jquery.js"></script>
    <script src="/public/js/wind.js"></script>
    <script src="/public/js/publish.js"></script>

    <script src="/public/simpleboot/bootstrap/js/bootstrap.min.js"></script>
<?php if(APP_DEBUG): ?><style>
		#think_page_trace_open{
			z-index:9999;
		}
	</style><?php endif; ?>
<script>
    document.domain = "xinhuiwen.com";
</script>
</head>
<body>
<?php
 $type_arr = array(0=>'9',1=>'10',2=>'11',3=>'12',4=>'13',5=>'14'); ?>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="<?php echo U('Admin/News/index', array($id_type=>$_GET[$id_type]));?>">文章列表</a></li>
        <li><a href="<?php echo U('Admin/News/caogao', array($id_type=>$_GET[$id_type]));?>">草稿箱</a></li>
        <li><a href="<?php echo U('Admin/News/timer', array($id_type=>$_GET[$id_type]));?>">定时稿件</a></li>
    </ul>
    <form class="well form-search" id="query_form" method="post" action="<?php echo U('Admin/News/index', array($id_type=>$_GET[$id_type]));?>">
        文章标题：
        <input type="text" id="newsTitle" name="newsTitle" style="width: 120px;" value="<?php echo ($formParam["newsTitle"]); ?>" placeholder="文章标题...">
        文章类型：
        <select class="select_2" name="news_type" id="news_type">
            <?php if(is_array($type_list)): foreach($type_list as $key=>$vo): ?><option <?php if($select_type == $vo['id']): ?>selected="selected"<?php endif; ?> value="<?php echo ($vo["id"]); ?>"><?php echo ($vo["name"]); ?></option><?php endforeach; endif; ?>
        </select>
        文章分类：
        <select class="select_2" name="category" id="category">
            <option value='' <?php echo ($cate_sel); ?>>全部</option>
            <?php if(is_array($formParam["categoryId"])): foreach($formParam["categoryId"] as $key=>$vo): ?><option value="<?php echo ($vo["type_id"]); ?>" <?php echo ($vo["selected"]); ?> ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; ?>
        </select>
        <?php if($id_type == 'column_id'): ?><input type="hidden" name="column_id" value="<?php echo ($id_val); ?>">
            <?php else: ?>
            <input type="hidden" name="area_id" value="<?php echo ($id_val); ?>"><?php endif; ?>
        <input type="button" name="query_form_btn" id="queryBtn" data-action="<?php echo U('Admin/News/index', array($id_type=>$_GET[$id_type]));?>"
                class="btn btn-primary" value="查询"/><br/><br/>
                
        <?php if($id_type == 'column_id'): ?><!-- 常规栏目 才有 栏目类型-->
            <a href="<?php echo U('Admin/NewsColumn/index',array( $id_type=>$id_val));?>" class="btn btn-primary" >栏目类型</a><?php endif; ?>
        <!-- <a href="<?php echo U('Admin/NewsManage/figure',array( 'news_id'=>$news_id,$id_type=>$id_val));?>" class="btn btn-primary" >轮播图</a> -->
        <a href="<?php echo U('Admin/NewsManage/figurelist',array( 'news_id'=>$news_id,$id_type=>$id_val));?>" class="btn btn-primary" >轮播图列表</a>
        <a href="<?php echo U('Admin/NewsManage/publish',array( 'special_id'=>$special_id,$id_type=>$id_val));?>" class="btn btn-primary" >快捷发布</a>
        <a href="<?php echo U('Admin/NewsManage/pictureAdd',array( 'news_id'=>$news_id,$id_type=>$id_val));?>" class="btn btn-primary" >添加图集文章</a>
        <a href="<?php echo U('Admin/NewsVideo/index',array( 'special_id'=>$special_id,$id_type=>$id_val));?>" class="btn btn-primary" >视频</a>
        <a href="<?php echo U('Admin/Special/specialAdd',array('special_id'=>$special_id,$id_type=>$id_val));?>" class="btn btn-primary" >专题</a>
        <?php if(($live_open == 1) AND ($live_role == 1)): ?><a href="<?php echo U('Admin/live/add',array('special_id'=>$special_id,$id_type=>$id_val,'add_from'=>1));?>" class="btn btn-primary" >直播</a><?php endif; ?>
        <a  class="btn btn-primary"  id="newsDel">删除</a>&nbsp;&nbsp;
        <a href="<?php echo U('Admin/NewsColumnEntrance/index',array( 'news_id'=>$news_id,$id_type=>$id_val));?>" class="btn btn-primary" >入口列表</a>
    </form>

    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
            	<th></th>
                <th>文章名称</th>
                <th>文章类型</th>
                <th>发布渠道</th>
                <th>编辑</th>
                <th>来源</th>
                <th>创建时间</th>
                <th>排序日期</th>
                <th>权重</th>
                <th>打赏</th>
            </tr>
            </thead>
            <tbody>
            <?php if(is_array($carousel_figure_data)): foreach($carousel_figure_data as $key=>$carousel_figure_vo): ?><tr>
                	<td><input name="news_ids[]"  type="checkbox" value="<?php echo ($carousel_figure_vo["news_id"]); ?>"></td>
                    <td>
                         <a href="<?php echo U('Admin/NewsManage/figure', array('news_id'=>$carousel_figure_vo['news_id'], $id_type=>$id_val));?>"><?php echo ($carousel_figure_vo["title"]); ?></a>
                         <input type="button" id="refresh" value="刷新" onclick="refresh_news('<?php echo ($carousel_figure_vo["news_id"]); ?>')">
                    </td>
                    <td><?php echo ($carousel_figure_vo["type_zh"]); ?></td>
                    <td><?php echo ($carousel_figure_vo["pub"]); ?></td>
                    <td><?php echo ($carousel_figure_vo["username"]); ?></td>
                    <td><?php echo ($carousel_figure_vo["source_name"]); ?></td>
                    <td><?php echo ($carousel_figure_vo["create_time"]); ?></td>
                    <td><?php echo ($carousel_figure_vo["refresh_time"]); ?></td>
                    <td><input type="text" name="weight" id="weight_<?php echo ($carousel_figure_vo["news_id"]); ?>" value="<?php echo ($carousel_figure_vo["weight"]); ?>" disabled="disabled" size="4">
                        <a id="edit_weight_<?php echo ($carousel_figure_vo["news_id"]); ?>" href='javascript:void(0);' onclick="update_weight('<?php echo ($carousel_figure_vo["news_id"]); ?>')">修改</a>
                        <input type="hidden" name="old_weight" id="old_weight_<?php echo ($carousel_figure_vo["news_id"]); ?>" value="<?php echo ($carousel_figure_vo["weight"]); ?>">
                    </td>
                    <td><a href="<?php echo U('Admin/News/news_reward_list',array('news_id'=>$vo['news_id']));?>" ><?php echo ($vo["hw_money_total"]); ?>汇闻币</a></td>
                </tr><?php endforeach; endif; ?>
            
            <?php if(is_array($data)): foreach($data as $key=>$vo): ?><tr>
                	<td><input name="news_ids[]"  type="checkbox" value="<?php echo ($vo["news_id"]); ?>"></td>
                	
                    <td>
                         <?php if($vo["type"] == 4): ?><!--<a href="<?php echo U('Admin/NewsVideo/index', array('news_id'=>$vo['news_id'], $id_type=>$id_val));?>" ><?php echo ($vo["title"]); ?></a>-->
                             <a href="<?php echo U('Admin/News/editapi', array('news_id'=>$vo['news_id'], $id_type=>$id_val));?>" ><?php echo ($vo["title"]); ?></a>
                             <span style="font-weight:600;">
								(
								<?php
 if($vo['video_status'] == '1'){ echo "转码中"; }elseif($vo['video_status'] == '2'){ echo "转码成功"; }elseif($vo['video_status'] == '3'){ echo "转码失败"; }else{echo "转码成功";} ?>
								)
							</span>
						<?php elseif($vo["type"] == 3): ?>
                             <a href="<?php echo U('Admin/Special/index', array('news_id'=>$vo['news_id'],'special_id'=>$vo['special_news_id'], $id_type=>$id_val));?>" ><?php echo ($vo["title"]); ?></a>

						<?php elseif($vo["type"] == 5): ?>
                             <!--<a href="<?php echo U('Admin/NewsManage/pictureAdd', array('news_id'=>$vo['news_id'], $id_type=>$id_val));?>" ><?php echo ($vo["title"]); ?></a>-->
                             <a href="<?php echo U('Admin/News/editapi', array('news_id'=>$vo['news_id'], $id_type=>$id_val));?>" ><?php echo ($vo["title"]); ?></a>
						<?php else: ?>
                             <a
                             <?php if(!in_array($vo['type'],$type_arr) || (in_array($vo['type'],$type_arr) && $vo['from_status'] == 1)){ ?>
                                href="<?php echo U('Admin/News/editapi', array('news_id'=>$vo['news_id'], $id_type=>$id_val));?>"
                             <?php }else if(in_array($vo['type'],$type_arr) && $live_role == 1 && $vo['live_status'] == 0){ ?>
                                href="<?php echo U('Admin/live/manage', array('news_id'=>$vo['news_id'], $id_type=>$id_val,'add_from'=>1));?>"
                             <?php }else if(in_array($vo['type'],$type_arr) && $live_role == 1 && $vo['live_status'] == 1){ ?>
                                href="<?php echo U('Admin/News/editapi', array('news_id'=>$vo['news_id'], $id_type=>$id_val));?>"
                             <?php } ?>
                             <?php if(in_array($vo['type'],$type_arr) && $live_role == 0){ echo "onclick='return false' style='color:grey'";}?>
                             > <?php echo ($vo["title"]); ?></a><?php endif; ?>


                        <?php if($vo["type"] != 2): ?><input type="button" id="full" value="通栏" <?php if(in_array($vo['type'],$type_arr) && $live_role == 0){ echo "onclick='return false' style='color:grey'";} else{ ?> onclick="setFull('<?php echo ($vo["news_id"]); ?>')" <?php } ?>><?php endif; ?>
                        <?php if(($vo["type"] != 2) and ($vo["top_status"] != 1)): ?><input type="button" id="refresh" value="刷新" <?php if(in_array($vo['type'],$type_arr) && $live_role == 0){ echo "onclick='return false' style='color:grey'";} else{ ?> onclick="refresh_news('<?php echo ($vo["news_id"]); ?>')" <?php } ?>><?php endif; ?>
                    </td>
                    <td><?php echo ($vo["type_zh"]); ?></td>
                    <td><?php echo ($vo["pub"]); ?></td>
                    <td><?php echo ($vo["username"]); ?></td>
                    <td><?php echo ($vo["source_name"]); ?></td>
                    <td><?php echo ($vo["create_time"]); ?></td>
                    <td><?php if(($vo["type"] != 2) and ($vo["top_status"] != 1)): echo ($vo["refresh_time"]); endif; ?></td>
                    <td><input type="text" name="weight" id="weight_<?php echo ($vo["news_id"]); ?>" value="<?php echo ($vo["weight"]); ?>" disabled="disabled" size="4">
                        <a id="edit_weight_<?php echo ($vo["news_id"]); ?>" href='javascript:void(0);' <?php if(in_array($vo['type'],$type_arr) && $live_role == 0){ echo "onclick='return false' style='color:grey'";} else{ ?> onclick="update_weight('<?php echo ($vo["news_id"]); ?>')" <?php } ?> >修改</a>
                        <input type="hidden" name="old_weight" id="old_weight_<?php echo ($vo["news_id"]); ?>" value="<?php echo ($vo["weight"]); ?>">
                    </td>
                    <td><a href="<?php echo U('Admin/News/news_reward_list',array('news_id'=>$vo['news_id']));?>" ><?php echo ($vo["hw_money_total"]); ?>汇闻币</a></td>
                </tr><?php endforeach; endif; ?>
            </tbody>
        </table>
    </form>
    <div class="pagination"><?php echo ($page); ?></div>
</div>
<script src="/public/js/common.js"></script>
<script src="/public/js/layer/layer.js"></script>
<script>
    function update_weight(news_id){
        edit_column = $("#edit_weight_"+news_id).html();
        column_befor = $("#old_weight_"+news_id).val();//原权重值
        column  = $("#weight_"+news_id).val(); //现权重值
        now_input_type = $("#weight_" + news_id); //权重 ID
        now_edit_type  = $("#edit_weight_" + news_id);  //修改 按钮ID

        var id_type = "<?php echo $id_type?>";
        if(id_type == 'column_id'){
            var column_id = $("[name='column_id']").val();
            var is_area   = 0;
        }else{
            var column_id = $("[name='area_id']").val();
            var is_area   = 1;
        }
        if(edit_column == "修改"){
            //处理 同时存在多个input编辑问题
            $(".input_edit").attr("disabled", "disabled");
            $(".edit_sub").html("修改");

            now_input_type.removeAttr("disabled");
            now_edit_type.html("确认");
        }else{
            if(column_befor == column){
                now_input_type.attr("disabled", "disabled");
                now_edit_type.html("修改");
            }else {
                $.post("<?php echo U('newsManage/editWeight');?>", {weight: column, news_id: news_id, column_id:column_id, is_area:is_area},
                        function (result) {
                            if (result == 1) {
                                now_input_type.attr("disabled", "disabled");
                                now_edit_type.html("修改");
                                location.reload()
                            }else{
                                alert("异常!")
                            }
                        }
                );
            }
        }
        $("#weight"+news_id).removeAttr("disabled");
    }

    function setFull(news_id){
    	//            content: "<?php if($_SERVER['SERVER_NAME'] == 'fzadmin.xinhuiwen.com') { echo U('Admin/NewsManage/setFull')?>"+'?news_id='+news_id+"<?php ;}else{echo U('Admin/NewsManage/setFull')?>"+'&news_id='+news_id+"<?php ;}?>",
        var id_type = "<?php echo $id_type?>";
        if(id_type == 'column_id'){
            var column_id = $("[name='column_id']").val();
            var is_area   = 0;
        }else{
            var column_id = $("[name='area_id']").val();
            var is_area   = 1;
        }
        layer.open({
            type: 2,
            //skin: 'layui-layer-lan',
            title: '通栏设置',
            fix: false,
            shadeClose: true,
            maxmin: true,
            area: ['1000px', '500px'],
            content: "<?php echo U('Admin/NewsManage/setFull')?>"+'&news_id='+news_id+'&column_id='+column_id+'&is_area='+is_area+"<?php ;?>",
            end: function(){
                location.reload();
            }
        });
    }

    function refresh_news(news_id){
        var id_type = "<?php echo $id_type?>";
        if(id_type == 'column_id'){
            var column_id = $("[name='column_id']").val();
            var is_area   = 0;
        }else{
            var column_id = $("[name='area_id']").val();
            var is_area   = 1;
        }
        $.post("<?php echo U('Admin/NewsManage/refreshNews')?>",{news_id:news_id,column_id:column_id,is_area:is_area}, function(result){
            if(result == '1'){
                var msg = '刷新成功';
            }else{
                var msg = '刷新失败';
            }

            alert(msg);
            window.location.reload();
        });
    }
    $(document).ready(function () {

        $('input[name="query_form_btn"]').click(function () {
            $('#query_form').attr('action', $(this).attr('data-action'));
            $('#query_form').submit();
        });



    });

    $("#newsDel").click(function(){
   	    var boxes = $("[name='news_ids[]']");
        var id_type = "<?php echo $id_type?>";
        if(id_type == 'column_id'){
            var column_id = $("[name='column_id']").val();
            var is_area   = 0;
        }else{
            var column_id = $("[name='area_id']").val();
            var is_area   = 1;
        }
   	    var news_checbox = []
        for(i=0;i<boxes.length;i++){
            if(boxes[i].checked == true){
           	 news_checbox.push(boxes[i].value);
            }
        }
   	 
   	 if(news_checbox == ''){
   		 alert('请选择要删除的文章!');
   		 return false;
   	 }
        $.post("<?php echo U('Admin/Special/newsDel')?>",{
        	news_checbox:news_checbox,is_area:is_area,column_id:column_id},function(result){
        	if(result > '0'){
        		var msg = '删除成功';
        	}else{
        		var msg = '删除失败';
        	}
        	
    		alert(msg);
    		location.reload();
          });
    })
</script>
<script>
$(document).ready(function(){
	$('#news_type').change(function(sel){
		var form_url     = $("#queryBtn").attr("data-action");
		$("#queryBtn").attr("data-action", '');
		var select_type  = $("#news_type").val();
		//var name		 = $("#newsTitle").val();
		//var new_form_url = form_url+'&news_type='+select_type+'&newsTitle='+name;
		var new_form_url = form_url+'&news_type='+select_type;
		$("#queryBtn").attr("data-action", new_form_url);
	})
	
	$("#newsTitle").blur(function(){
    	var newsTitle = $("#newsTitle").val();
      	if(newsTitle){
            var select_type  = $("#news_type").val();
            var form_url     = $("#queryBtn").attr("data-action");
            $("#queryBtn").attr("data-action", '');
            var new_form_url = form_url+'&news_type='+select_type+'&newsTitle='+newsTitle;
            $("#queryBtn").attr("data-action", new_form_url);
      	}
    });
	/* $('#queryBtn').click(function(){
		var form_url     = $("#queryBtn").attr("data-action");
		$("#queryBtn").attr("data-action", '');
		var select_type  = $("#news_type").val();
		var name		 = $("#newsTitle").val();
		var new_form_url = form_url+'&news_type='+select_type+'&newsTitle='+name;
		$("#queryBtn").attr("data-action", new_form_url);
		alert(new_form_url);return;
		$(this).submit();
	}) */
})
</script>
</body>
</html>